package service.impl;

import service.SecurityService;
import utils.PasswordUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Description: 模拟数据库操作服务接口实现
 */
public class SecurityServiceImpl implements SecurityService {

    /**
      * @Description: 模拟数据库读入
      * @Param: [loginName]
      * @Return: java.lang.String
      * @Author: Bink
      * @DateTime: 2021/6/9 10:14 上午
     **/
    @Override
    public Map<String, String> findPasswordByLoginName(String loginName) {
        return "Bink".equals(loginName)? PasswordUtil.encryptPassword("131"):null;
    }

    /**
      * @Description: 模拟查询角色
      * @Param: [loginName]
      * @Return: role list
      * @Author: Bink
      * @DateTime: 2021/6/9 5:31 下午
     **/
    @Override
    public List<String> findRoleByLoginName(String loginName) {
        if ("Bink".equals(loginName)){
            return List.of("admin");
        }
        return null;
    }

    @Override
    public List<String> findPermissionByLoginName(String loginName) {
        if ("Bink".equals(loginName)){
            return List.of("user:add", "user:delete", "user:update");
        }
        return null;
    }
}
